#!/usr/bin/env bash

# 作者: Andy <admin_at_simplemail.cn>

#---------------------------------------------------------------------
# 本文件是 SimpleMail 的一部分，它是一个针对 Red Hat(R) Enterprise Linux、CentOS、Debian 和 Ubuntu 的开源邮件服务器解决方案。
#
# SimpleMail 是自由软件：您可以根据自由软件基金会发布的 GNU 通用公共许可证的条款，重新分发和/或修改它。
# 许可证的版本可以是第 3 版，或者（根据您的选择）任何更高版本。
#
# 分发 SimpleMail 是希望它能有用，但没有任何保证；甚至没有适销性或特定用途适用性的暗示保证。
# 有关更多详细信息，请参阅 GNU 通用公共许可证。
#
# 您应该已经收到了一份 GNU 通用公共许可证副本。如果没有，请访问 <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------

# Variables for Postfix and related.

#
# You do *NOT* need to modify them.
#
# ---- Postfix ----
export SYS_USER_POSTFIX='postfix'
export SYS_GROUP_POSTFIX='postfix'

export POSTFIX_ROOTDIR='/etc/postfix'
export POSTFIX_RC_SCRIPT_NAME='postfix'

# Log file
export MAILLOG='/var/log/maillog'

if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
    export MAILLOG='/var/log/mail.log'
    export MAILLOG_INFO='/var/log/mail.info'
    export MAILLOG_ERROR='/var/log/mail.err'
    export MAILLOG_WARN='/var/log/mail.warn'

elif [ X"${DISTRO}" == X'FREEBSD' ]; then
    export POSTFIX_ROOTDIR='/usr/local/etc/postfix'

elif [ X"${DISTRO}" == X'OPENBSD' ]; then
    export SYS_USER_POSTFIX='_postfix'
    export SYS_GROUP_POSTFIX='_postfix'
fi

# You do *NOT* need to modify them.
export POSTFIX_CHROOT_DIR='/var/spool/postfix'

export POSTFIX_FILE_MAIN_CF="${POSTFIX_ROOTDIR}/main.cf"
export POSTFIX_FILE_MASTER_CF="${POSTFIX_ROOTDIR}/master.cf"
export POSTFIX_FILE_ALIASES="${POSTFIX_ROOTDIR}/aliases"
export POSTFIX_FILE_HELO_ACCESS="${POSTFIX_ROOTDIR}/helo_access.pcre"
export POSTFIX_FILE_SMTPD_COMMAND_FILTER="${POSTFIX_ROOTDIR}/command_filter.pcre"

export POSTFIX_FILE_HEADER_CHECKS="${POSTFIX_ROOTDIR}/header_checks"
export POSTFIX_FILE_BODY_CHECKS="${POSTFIX_ROOTDIR}/body_checks.pcre"
# used for sender white/blacklist with pcre support
export POSTFIX_FILE_SENDER_ACCESS="${POSTFIX_ROOTDIR}/sender_access.pcre"

export POSTSCREEN_FILE_DNSBL_REPLY="${POSTFIX_ROOTDIR}/postscreen_dnsbl_reply"
export POSTSCREEN_FILE_ACCESS_CIDR="${POSTFIX_ROOTDIR}/postscreen_access.cidr"

# Default transport or LDA (local deliver agent).
export TRANSPORT="${TRANSPORT:=${DOVECOT_LDA_DELIVER}}"

# Set 'message_size_limit', in 'byte' and 'kilobytes'.
# Default is 15M (final message will be slight larger after encoding).
export MESSAGE_SIZE_LIMIT_MB="${MESSAGE_SIZE_LIMIT_MB:=15}"
export MESSAGE_SIZE_LIMIT_BYTES="$((MESSAGE_SIZE_LIMIT_MB * 1024 * 1024))"
export MESSAGE_SIZE_LIMIT_KB="$((MESSAGE_SIZE_LIMIT_MB * 1024))"

# LDAP/MYSQL/PGSQL lookup configuration files.
if [ X"${BACKEND}" == X'OPENLDAP' ]; then
    export POSTFIX_LOOKUP_DB='ldap'
elif [ X"${BACKEND}" == X'MYSQL' ]; then
    export POSTFIX_LOOKUP_DB='mysql'
elif [ X"${BACKEND}" == X'PGSQL' ]; then
    export POSTFIX_LOOKUP_DB='pgsql'
else
    export POSTFIX_LOOKUP_DIR="${POSTFIX_ROOTDIR}/lookups"
fi

export POSTFIX_LOOKUP_DIR="${POSTFIX_ROOTDIR}/${POSTFIX_LOOKUP_DB}"
export POSTFIX_MAIL_REINJECT_PORT='10025'
export POSTFIX_MLMMJ_REINJECT_PORT='10028'
